//
//  SimDashLineView.m
//
//  Created by LiuXubin on 14/12/11.
//

#import "SimDashLineView.h"
#import "SimDefine.h"

@implementation SimDashLineView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        _dashWidth = 7;
        _lineWidth = 2;
        _dashGap = 3;
        _lineColor = HEXRGBCOLOR(0xe4e4e4);
    }
    
    return self;
}

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, _lineWidth);
    CGContextSetStrokeColorWithColor(context, _lineColor.CGColor);
    CGFloat lengths[] = {_dashWidth, _dashGap};
    CGContextSetLineDash(context, 0, lengths, 2);
    CGContextMoveToPoint(context, 0, 0);
    if (_isVertical) {
        CGContextAddLineToPoint(context, 0, rect.size.height);
    }
    else{
        CGContextAddLineToPoint(context, rect.size.width, 0);
    }
    CGContextStrokePath(context);
}

@end
